package q1;

import java.util.Arrays;
import java.util.List;

public class TreeNode {
    private Integer id;
    private List<TreeNode> children;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public List<TreeNode> getChildren() {
        return children;
    }

    public void setChildren(List<TreeNode> children) {
        this.children = children;
    }

    public TreeNode(Integer id) {
        this.id = id;
    }

    public TreeNode(Integer id, List<TreeNode> children) {
        this.id = id;
        this.children = children;
    }


    public static TreeNode getNextTreeNode(Tree tree){
        TreeNode root = tree.getRoot();
        if (root == null) {
            return null;
        }
        if (root.getChildren() != null){
            return root.getChildren().get(0);
        }
        //存储children时升序存储，最小的在最左边

        //读取的时候获取子节点第一个子类children为空的元素返回

        //再次获取子类的第二个元素，递归判断子类getChildren是否为空

        //。。。。。。
        return null;
    }

    public static void main(String[] args) {

        //Node11 和 子项Node111
        TreeNode treeNode111 = new TreeNode(111);
        List<TreeNode> Node11_children = Arrays.asList(treeNode111);
        TreeNode treeNode11 = new TreeNode(11,Node11_children);

        //Node12 和 子项Node121,Node122
        TreeNode treeNode121 = new TreeNode(121);
        TreeNode treeNode122 = new TreeNode(122);
        List<TreeNode> Node12_children = Arrays.asList(treeNode121,treeNode122);
        TreeNode treeNode12 = new TreeNode(12,Node12_children);

        List<TreeNode> treeNodes = Arrays.asList(treeNode11, treeNode12);

        TreeNode rootNode = new TreeNode(0,treeNodes);

        Tree tree = new Tree();
        tree.setRoot(rootNode);
        TreeNode nextTreeNode = getNextTreeNode(tree);

        System.out.println(nextTreeNode.getId());
    }
}
